﻿#region Using namespaces

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

using BOL.Apps.GeneNetworkBrowser.Analysis;

#endregion

namespace BOL.Apps.GeneNetworkBrowser.ViewModels
{
    public sealed class AnalysesTreeViewItemViewModel : TreeViewItemViewModel
    {
        #region TreeViewItemViewModel implementation

        private ObservableCollection<IAnalysis> _analyses;

        public AnalysesTreeViewItemViewModel(IEnumerable<IAnalysis> analyses, ProjectTreeViewItemViewModel vmProject)
            : base(vmProject, true)
        {
            _analyses = new ObservableCollection<IAnalysis>(analyses);
            _title = "Analyses";
        }

        protected override void LoadChildren()
        {
            foreach (var analysis in _analyses)
                base.Children.Add(new AnalysisTreeViewItemViewModel(analysis, this));
        }

        public void AddAnalysis(IAnalysis analysis)
        {
            _analyses.Add(analysis);
            base.Children.Add(new AnalysisTreeViewItemViewModel(analysis));
        }

        #endregion
    }
}
